
var myphoneno = '+17327101856';
function getObj(id) {
  return document.getElementById(id);
}

function stripHTML(str){
 var re= /<\S[^><]*>/g
 str=str.replace(re, "")
 return str;
}

function setText(o, id)
{
	//var id = "id_ph_no";
	var actValue = "";
	//alert('inside setPhNo');
	//alert(id);
      var actDivObj = getObj(id);
  	if(actDivObj != null) {
    		actValue = actDivObj.value;
    		//alert('inside='+actValue);
  	}

	//alert(actValue);
	myphoneno = actValue;
}

/** TravelDeals sends details of the SelectList used for Message, and the Contacts to which SMS needs to be sent **/
function telcoSvc(svcType, msg_sponsor, id_msg_prefix, msg_body, id_sent_by, id_info){

	var msgbase = "send sms..";
	//alert('telcoSvc');
	var mapId = google.mashups.getObjectById('maptraveldeals');
	var entry = mapId.getSelectedEntry();
	//alert('entry: moment of truth');
	//alert(entry);
	var entrytitle = entry.title;
	var entrytitlevalue = entry.title.$t;
	//alert(entrytitle);
	//alert(entrytitlevalue);

	var sentByObj = getObj(id_sent_by);
	var sentByValue = sentByObj.value;

	var msgPrefixObj = getObj(id_msg_prefix);

	 var msg = msg_sponsor+ ": From " + sentByValue + ". " + msgPrefixObj.value + " --> " + entrytitlevalue;
 	 //alert(msg);


	 // id_info contains the id of the element that has the data to be processed
 	if(svcType == "gsms") {
   	//alert('outside gsms');
   	handleGroupSms(msg, sentByValue , id_info);
 }
  
  //alert('EXISTING telco service mashup');
}

/** Meetup sends details of the Feed used for Message, and the Contacts to which SMS needs to be sent 
phonesourcetype:0 (phone no. in author tag)
phonesourcetype:1 (phone no. in summary tag)
placetype:0 (All place details...)
placetype:1 (Single place details...)
**/

function telcoSvcMeetup(svcType, msg_sponsor, id_msg_prefix, msg_body, id_list_recepients, id_list_places, phonesourcetype, placetype )
{
	var msgbase = "sms..";
	alert(' Powered By SDP: Thanks for using Group SMS feature');
      var feedPlaces = google.mashups.getObjectById(id_list_places).getData();
	//alert(feedPlaces.size());
      var feedContacts = google.mashups.getObjectById(id_list_recepients).getData();
	//alert(feedContacts.size());

	var msgPrefixObj = getObj(id_msg_prefix);
      var msg = msgPrefixObj.value + ": ";

	if(placetype == 0) {
	for(var index=0; index<feedPlaces.size(); index++) {
		var currEntry = feedPlaces.entryAt(index);
		// alert(currEntry);
		// alert(currEntry.title.$t);
		msg = msg + currEntry.title.$t + ". " + "\n";
	}
	}

	if(placetype==1) {
		//var mapId = google.mashups.getObjectById('maptraveldeals');
		// modified: jan 15, accept select entry from list rather than map.
		var mapId = google.mashups.getObjectById('id_places');
		var entry = mapId.getSelectedEntry();
		var entrytitle = entry.title;
		var entrytitlevalue = entry.title.$t;
		var entrysummaryvalue = entry.summary.$t;

		msg = msg + entrytitlevalue + ". " + entrysummaryvalue;
		msg = stripHTML(msg);
		// modified: jan 15, see msg to be sent.
		//alert(msg);
	}

	for(var index=0; index<feedContacts.size(); index++) {
		var currEntry = feedContacts.entryAt(index);
		// alert(currEntry);
		var currno;
		if(phonesourcetype == 0) {
			currno = currEntry.author.name.$t;
		} else if (phonesourcetype == 1) {
			currno = currEntry.summary.$t;
		}
      	sendSms(currno,msg, index+1, feedContacts.size());
	}

 	 //alert(msg);
}


function handleGroupSms(msg, contactinfo, id_info) {
	//alert('handlegroupsms');
	var groupValueObj = getObj(id_info);
	//alert(groupValueObj);
	//alert(groupValueObj.length);

	for(var i=0; i<groupValueObj.length; i++) {
         var currval = groupValueObj.options[i];
	   //alert(currval);
	   var currno = currval.value;
	   //alert(currno + " " + msg);
	   sendSms(currno,msg, i+1, length);
	}

	// for each value.. send sms...
}

function sendSms(phno, msg, index, totalno) {
 var licenseUser = "yugans@hotmail.com";
 var licensePswd = "wwsdpg";
 var licenseEmail = "yugans@prinove.com";

 //alert(phno + "" + msg);
 alert("Sending SMS " + index + " of " + totalno + " to " + phno);
 var smshref = "http://ws.strikeiron.com/StrikeIron/globalsmspro2_5/SMSTextMessaging/SendMessage?LicenseInfo.RegisteredUser.UserId="+licenseUser+"&LicenseInfo.RegisteredUser.Password="+licensePswd+"&SendMessage.ToNumber="+phno+"&SendMessage.FromName=SDPSecuredTravelApp&SendMessage.MessageText="+msg;
 //alert(smshref);
 // http://ws.strikeiron.com/StrikeIron/globalsmspro2_5/SMSTextMessaging/SendMessage?LicenseInfo.RegisteredUser.UserId=yugans@hotmail.com&LicenseInfo.RegisteredUser.Password=wwsdpg&SendMessage.ToNumber=+919999443026&SendMessage.FromName=SDPSecuredTravelApp&SendMessage.MessageText=testsms
 //var smshref = "http://ws.strikeiron.com/StrikeIron/globalsmspro2_5/SMSTextMessaging/SendMessage?LicenseInfo.UnregisteredUser.EmailAddress="+licenseEmail+"&SendMessage.ToNumber="+phno+"&SendMessage.FromName=SDPSecuredTravelApp&SendMessage.MessageText="+msg;
 window.open(smshref, 'sms', null);

}

/* type=0: Phone number in Author
   type=1: Phone number in Summary
*/
function confCallInvoke(id_contacts, type) {
 //alert(phno + "" + msg);
 alert("Sending confcall with "+ type);
 //var smshref = "http://131.124.96.222:8001/sdpservice/ConfrenceService?userid=entia&phone1=18602585055&phone2=17327101856&tokenid=88888&time=7474744764";
  var confref = "http://15.178.174.141:8001/sdpservice/ConfrenceService?userid=entia&tokenid=88888&time=7474744764";

      var feedContacts = google.mashups.getObjectById(id_contacts).getData();
	//alert(feedContacts.size());

	for(var index=0; index<feedContacts.size(); index++) {
		var currEntry = feedContacts.entryAt(index);
		var phidx = index+1;
		// alert(currEntry);
		// alert(currEntry.author.name.$t);
		var currno;
		if(type == 0) {
			currno = currEntry.author.name.$t;
		} else if (type == 1) {
			currno = currEntry.summary.$t;
		}
		alert(currno);
		confref = confref + "&phone"+phidx+"="+currno;
      	//sendSms(currno,msg, index+1, feedContacts.size());
	}
	alert(confref);
 	window.open(confref, 'sms', null);
 	//alert(smshref);
}


<!-- JAVASCRIPT -->

function getObj(id) {
	return document.getElementById(id);
}

function rand ( n )
{
  return ( Math.floor ( Math.random ( ) * n + 1 ) );
}

function findPlaces(islist, ismap, clearoverlay)
{
	var baseurl = "http://pipes.yahoo.com/pipes/pipe.run?_id=urhkrL_N3BGBwlgZJxOy0Q&_render=rss";
	var addr = "New York";
	var biz="Resturants";
	var rnd="483";
	var star="";

	// get value from textbox
	var idvisitObj = getObj('id_visit');
	if(idvisitObj != null) {
		biz = idvisitObj.value;
	}

	var idstarObj = getObj('id_star');
	if(idstarObj != null) {
		star = idstarObj.value;
	}

	var idaddrObj = getObj('id_addr');
	if(idaddrObj != null) {
		addr = idaddrObj.value;
	}

	// invoke URL and get datafeed
	var dataFeedUrl = baseurl+"&addr="+escape(addr)+"&biz="+biz+"&star="+star+"&rnd=483";
	//alert('findPl'+dataFeedUrl);
	//alert('findpl');
	//alert(islist);
	if(islist == 1) {
		refreshList(dataFeedUrl, 'id_places');
	}
	// temp comment...
	//alert(ismap);
	if(ismap == 1) {
		refreshMap(dataFeedUrl, 'id_map_travelmeetup', clearoverlay);
	}
	// Set data feed for the list dynamically
}


function refreshList(dataFeedUrl, id) 
{
	var listModulePlaces = google.mashups.getObjectById(id);
	listModulePlaces.setData(dataFeedUrl);
}

function refreshMap(dataFeedUrl, id, clearoverlay)
{
	//alert('refresh map'+dataFeedUrl + ' ' + id);
	var mapModulePlaces = google.mashups.getObjectById(id);
	//alert("refreshMap");
	if(clearoverlay == 1) {
		mapModulePlaces.getMap().clearOverlays();
	}
      mapModulePlaces.getMap().addOverlay(new GGeoXml(dataFeedUrl));
	// mapModulePlaces.showAllMarkers();

}

function centerMap(id, id_addr)
{
	alert('Map Placed to user Location'); 
	var mapModulePlaces = google.mashups.getObjectById(id);
	// alert('Set Location');
	var idAddrObj = getObj(id_addr);
	var addr = idAddrObj.value;
	//alert(addr);
	mapModulePlaces.centerOnLocation(addr);
	
}


/* For a Selected Picture, handle it (Publish or get details) */
function handlePicture(id_places, id_photos_list)
{

// http://pipes.yahoo.com/pipes/pipe.run?_id=VKAicC3H3BGiXuJjYEsBXw&_render=rss&locationinput1=New+York%2C+NY&textinput1=Theater
// GPath: media:group/media:content/@url

		// get selected title
		/*
		var mapId = google.mashups.getObjectById(id_places);
		var entry = mapId.getSelectedEntry();
		var entrytitle = entry.title;
		var entrytitlevalue = entry.title.$t;
		var entrysummaryvalue = entry.summary.$t;
		*/

		//alert(entrysummaryvalue);

		// get selected photo
		var photolist = google.mashups.getObjectById(id_photos_list);
		var entry1 = photolist.getSelectedEntry();
		if(entry1 == null) {
			alert('Please select a picture! ');
			return;
		}
		var entrytitle1 = entry1.title;
		var entrytitlevalue1 = entry1.title.$t;
		var entrysummaryvalue1 = entry1.summary.$t;
		var mediagroup = entry1.media$group;
		var mediacontent = mediagroup[0].media$content;
		var image_url = mediacontent.url;
		//alert(url);
		alert('Publish: ' + image_url);
		var url = 'http://15.178.174.141:8090/sdp/UploadPhoto1?image_url=' + image_url;
		alert('Invoking: ' + url);
		window.open(url, 'uploadPhoto', null);

}

function findPictures(id_photos_list) {
	var mapId = google.mashups.getObjectById('id_places');
	var entry = mapId.getSelectedEntry();
	if(entry == null) {
		alert('Please select an entry! ');
		return;
	}
	
	var entrytitle = entry.title;
	var entrytitlevalue = entry.title.$t;
	alert(entrytitlevalue);
	
	var entryvalues = entrytitlevalue.split(" ");
	alert(entryvalues);
	var poi = entryvalues[0];
	for(i = 1; i < entryvalues.length; i++){
		poi = poi + "+" +entryvalues[i];
	//document.write("<br /> Element " + i + " = " + mySplitResult[i]); 
	}

	var url = 'http://pipes.yahoo.com/pipes/pipe.run?_id=VKAicC3H3BGiXuJjYEsBXw&_render=rss&locationinput1=Barcelona&textinput1=' + poi;
	alert(url);
      var photosList = google.mashups.getObjectById(id_photos_list);
      photosList.setData(url);

}

function findPOIPlaces(islist, ismap, clearoverlay,id)
{
	var baseurl = "http://pipes.yahoo.com/pipes/pipe.run?_id=urhkrL_N3BGBwlgZJxOy0Q&_render=rss";
	var addr = "New York";
	var biz="Resturants";
	var rnd="483";
	var star="";
	var geocoder = null;
	

	// get value from textbox
	var idvisitObj = getObj('id_visit');
	if(idvisitObj != null) {
		
		biz = idvisitObj.value.toUpperCase();
		//alert("biz: " +biz);
	}

	var idstarObj = getObj('id_star');
	if(idstarObj != null) {
		
		star = idstarObj.value;
		//alert("star: " + star);
	}

	var idaddrObj = getObj('id_addr');
	if(idaddrObj != null) {
		
		addr = idaddrObj.value;
		//alert("addr: " + addr);
		//geocoder = new GClientGeocoder();
		//if (geocoder) {
		//	geocoder.getLatLng(addr,alertPoint(point));
        //}
	}

	var mapModulePlaces = google.mashups.getObjectById(id);
	// alert('Set Location');
	mapModulePlaces.centerOnLocation(addr);
	var point = mapModulePlaces.getCenter();
	//alert("point:" + point.lat());
	//alert("point:" + point.lng());

	// invoke URL and get datafeed
	//http://15.178.174.141:8001/sdpservice/GetPOIData?lat=37.765444&lng=122.42654&poi=BANK

	var dataFeedUrl = "http://15.178.174.141:8001/sdpservice/GetPOIData?lat="+point.lat()+"&lng="+point.lng()+"&poi="+biz;
	alert('url: '+dataFeedUrl);
	//var listModulePlaces = google.mashups.getObjectById('id_places');
	//listModulePlaces.setData(dataFeedUrl);

	if(islist == 1) {
		refreshList(dataFeedUrl, 'id_places');
	}
	// temp comment...
	//alert(ismap);
	if(ismap == 1) {
		refreshMap(dataFeedUrl, 'id_map_travelmeetup', clearoverlay);
	}

//	refreshList(dataFeedUrl, 'id_places');
	//window.open(dataFeedUrl, 'getPoiData', null);
}

//function alertPoint(point){

//	alert("Inside alertPoint(point) method: " + point);
//}




